home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / WASTE 1.2a4 / WASTE C⁄C++ Headers / WASTE.h < prev   
Encoding:
C/C++ Source or Header  |  1995-12-10  |  32.4 KB  |  757 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.2a4 (December 1995)
  7.  *
  8.  *    Copyright (c) 1993-1995 Marco Piovanelli
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __CONDITIONALMACROS__
  17. #include <ConditionalMacros.h>
  18. #endif
  19.  
  20. #ifndef __TYPES__
  21. #include <Types.h>
  22. #endif
  23.  
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAWTEXT__
  29. #include <QuickdrawText.h>
  30. #endif
  31.  
  32. #ifndef __QUICKDRAW__
  33. #include <Quickdraw.h>
  34. #endif
  35.  
  36. #ifndef __SCRIPT__
  37. #include <Script.h>
  38. #endif
  39.  
  40. #ifndef __TEXTUTILS__
  41. #include <TextUtils.h>
  42. #endif
  43.  
  44. #ifndef __TEXTEDIT__
  45. #include <TextEdit.h>
  46. #endif
  47.  
  48. #ifndef __DRAG__
  49. #include <Drag.h>
  50. #endif
  51.  
  52. #ifndef __LONGCOORDINATES__
  53. #ifndef _LongCoords_
  54. #include "LongCoords.h"
  55. #endif
  56. #endif
  57.  
  58. // if we're using a pre-2.1 version of the Universal Headers, define EventModifiers
  59. #ifndef UNIVERSAL_INTERFACES_VERSION
  60. typedef unsigned short EventModifiers;
  61. #endif
  62.  
  63. #if defined(powerc) || defined (__powerc)
  64. #pragma options align=mac68k
  65. #endif
  66.  
  67. //    The macro WASTE_VERSION expands to the current version of WASTE,
  68. //    expressed in standard NumVersion format (see Types.h)
  69. //    The macro WASTE11 is obsolete but still supported for backward
  70. //    compatibility
  71.  
  72. #define WASTE_VERSION    0x01204004
  73. #define WASTE11
  74.  
  75. /*    result codes */
  76.  
  77. enum {
  78.     weCantUndoErr            =    -10015,    /* undo buffer is clear (= errAECantUndo) */
  79.     weEmptySelectionErr        =    -10013,    /* selection range is empty (= errAENoUserSelection) */
  80.     weNotHandledErr            =    -1708,    /* please use default behavior (= errAEEventNotHandled) */
  81.     weUnknownObjectTypeErr    =    -9478,    /* specified object type is not registered */
  82.     weObjectNotFoundErr        =    -9477,    /* no object found at specified offset */
  83.     weReadOnlyErr            =    -9476,    /* instance is read-only */
  84.     weUndefinedSelectorErr    =    -50        /* unknown selector (= paramErr) */
  85. };
  86.  
  87. /*    alignment styles */
  88.  
  89. enum {
  90.     weFlushLeft         =    -2,        /* flush left */
  91.     weFlushRight        =    -1,        /* flush right */
  92.     weFlushDefault        =     0,        /* flush according to system direction */
  93.     weCenter            =     1,        /* centered */
  94.     weJustify            =     2        /* fully justified */
  95. };
  96.  
  97. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  98.  
  99. enum {
  100.     weDoFont                =    0x0001,
  101.     weDoFace                =    0x0002,
  102.     weDoSize                =    0x0004,
  103.     weDoColor                =    0x0008,
  104.     weDoAll                    =    weDoFont + weDoFace + weDoSize + weDoColor,
  105.     weDoAddSize                =    0x0010,
  106.     weDoToggleFace            =    0x0020,
  107.     weDoReplaceFace            =    0x0040,
  108.     weDoPreserveScript        =    0x0080,
  109.     weDoExtractSubscript    =    0x0100,
  110.     weDoFaceMask            =    0x0200
  111. };
  112.  
  113. /*    values for the edge parameter in WEGetOffset etc. */
  114.  
  115. enum {
  116.     kLeadingEdge = -1,        /* point is on the leading edge of a glyph */
  117.     kTrailingEdge = 0,        /* point is on the trailing edge of a glyph */
  118.     kObjectEdge = 2            /* point is in the middle of an embedded object */
  119. };
  120.  
  121. /*    values for WEFeatureFlag feature parameter */
  122.  
  123. enum {
  124.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  125.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  126.     weFReadOnly            =    5,        /* disallow modifications */
  127.     weFUndo                =    6,        /* support WEUndo() */
  128.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  129.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  130.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  131.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  132.     weFDrawOffscreen    =    11,        /* draw text offscreen for smoother visual results */
  133.     weFInhibitRedraw    =    12,        /* don't redraw text */
  134.     weFMonoStyled        =    13,        /* disallow style changes */
  135.     weFInhibitColor        =    31        /* draw in black & white only */
  136. };
  137.  
  138. /*    values for WENew flags parameter */
  139.  
  140. enum {
  141.     weDoAutoScroll        =    1L << weFAutoScroll,
  142.     weDoOutlineHilite    =    1L << weFOutlineHilite,
  143.     weDoReadOnly        =    1L << weFReadOnly,
  144.     weDoUndo            =    1L << weFUndo,
  145.     weDoIntCutAndPaste    =    1L << weFIntCutAndPaste,
  146.     weDoDragAndDrop        =    1L << weFDragAndDrop,
  147.     weDoInhibitRecal    =    1L << weFInhibitRecal,
  148.     weDoUseTempMem        =    1L << weFUseTempMem,
  149.     weDoDrawOffscreen    =    1L << weFDrawOffscreen,
  150.     weDoInhibitRedraw    =    1L << weFInhibitRedraw,
  151.     weDoMonoStyled        =    1L << weFMonoStyled,
  152.     weDoInhibitColor    =    1L << weFInhibitColor
  153. };
  154.  
  155. /*    values for WEFeatureFlag action parameter */
  156.  
  157. enum {
  158.     weBitToggle = -2,    /* toggles the specified feature */
  159.     weBitTest,            /* returns the current setting of the specified feature */
  160.     weBitClear,            /* disables the specified feature */
  161.     weBitSet            /* enables the specified feature */
  162. };
  163.  
  164. /*    selectors for WEGetInfo and WESetInfo */
  165.  
  166. enum {
  167.     weCharToPixelHook    =    'c2p ',    /* CharToPixel hook */
  168.     weClickLoop            =    'clik',    /* click loop callback */
  169.     weCurrentDrag        =    'drag',    /* drag currently being tracked from WEClick() */
  170.     weDrawTextHook        =    'draw', /* text drawing hook */
  171.     weLineBreakHook        =    'lbrk',    /* line breaking hook */
  172.     wePixelToCharHook    =    'p2c ', /* PixelToChar hook */
  173.     wePort                =    'port',    /* graphics port */
  174.     weRefCon            =    'refc',    /* reference constant for use by application */
  175.     weScrollProc        =    'scrl',    /* auto-scroll callback */
  176.     weText                =    'text',    /* text handle */
  177.     weTranslateDragHook =    'xdrg', /* drag translation callback */
  178.     weTSMDocumentID        =    'tsmd',    /* Text Services Manager document ID */
  179.     weTSMPreUpdate        =    'pre ',    /* Text Services Manager pre-update callback */
  180.     weTSMPostUpdate        =    'post',    /* Text Services Manager post-update callback */
  181.     weURLHint            =    'urlh'    /* URL hint string for Internet Config */
  182. };
  183.  
  184. /*    values for WEInstallObjectHandler handlerSelector parameter */
  185.  
  186. enum {
  187.     weNewHandler        =    'new ',        /* new handler */
  188.     weDisposeHandler    =    'free',        /* dispose handler */
  189.     weDrawHandler        =    'draw',        /* draw handler */
  190.     weClickHandler        =    'clik',        /* click handler */
  191.     weStreamHandler        =    'strm'        /* stream handler */
  192. };
  193.  
  194. /*    action kinds */
  195.  
  196. enum {
  197.     weAKNone            =    0,        /* null action */
  198.     weAKUnspecified        =    1,        /* action of unspecified nature */
  199.     weAKTyping            =    2,        /* some text has been typed in */
  200.     weAKCut                =    3,        /* the selection range has been cut */
  201.     weAKPaste            =    4,        /* something has been pasted */
  202.     weAKClear            =    5,        /* the selection range has been deleted */
  203.     weAKDrag            =    6,        /* drag and drop operation */
  204.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  205. };
  206.  
  207. /*    destination kinds for stream handler */
  208.  
  209. enum {
  210.     weToScrap            =    0,
  211.     weToDrag            =    1,
  212.     weToSoup            =    2
  213. };
  214.  
  215. typedef struct OpaqueWEReference *WEReference;
  216. typedef struct OpaqueWEObjectReference *WEObjectReference;
  217. typedef Handle WESoupHandle;
  218. typedef short WEActionKind;
  219. typedef char WEAlignment;
  220. typedef unsigned short WEStyleMode;
  221. typedef FourCharCode WESelector;
  222. typedef WEReference WEHandle;    /* obsolete, kept for backward compatibility */
  223.  
  224. typedef struct WERunInfo {
  225.     long                 runStart;    /* byte offset to first character of style run */
  226.     long                 runEnd;        /* byte offset past last character of style run */
  227.     short                 runHeight;    /* line height (ascent + descent + leading) */
  228.     short                 runAscent;    /* font ascent */
  229.     TextStyle             runStyle;    /* text attributes */
  230.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  231. } WERunInfo;
  232.  
  233.  
  234. /*    callback prototypes */
  235.  
  236. typedef pascal Boolean (*WEClickLoopProcPtr)(WEReference we);
  237. typedef pascal void (*WEScrollProcPtr)(WEReference we);
  238. typedef pascal void (*WETSMPreUpdateProcPtr)(WEReference we);
  239. typedef pascal void (*WETSMPostUpdateProcPtr)(WEReference we,
  240.         long fixLength, long inputAreaStart, long inputAreaEnd,
  241.         long pinRangeStart, long pinRangeEnd);
  242. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
  243.         ItemReference theItem, FlavorType requestedType, Handle putDataHere);
  244. typedef pascal void (*WEDrawTextProcPtr)(Ptr pText, long textLength, Fixed slop,
  245.         JustStyleCode styleRunPosition, WEReference we);
  246. typedef pascal long (*WEPixelToCharProcPtr)(Ptr pText, long textLength, Fixed slop,
  247.         Fixed *pixelWidth, char *edge, JustStyleCode styleRunPosition, Fixed hPos, WEReference we);
  248. typedef pascal short (*WECharToPixelProcPtr)(Ptr pText, long textLength, Fixed slop,
  249.         long offset, short direction, JustStyleCode styleRunPosition, long hPos, WEReference we);
  250. typedef pascal StyledLineBreakCode (*WELineBreakProcPtr)(Ptr pText, long textLength,
  251.         long textStart, long textEnd, Fixed *textWidth, long *textOffset, WEReference we);
  252. typedef pascal void (*WEWordBreakProcPtr)(Ptr pText, short textLength, short offset,
  253.         char edge, OffsetTable breakOffsets, ScriptCode script, WEReference we);
  254. typedef pascal short (*WECharByteProcPtr)(Ptr pText, short textOffset, ScriptCode script,
  255.         WEReference we);
  256. typedef pascal short (*WECharTypeProcPtr)(Ptr pText, short textOffset, ScriptCode script, WEReference we);
  257. typedef pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  258.         WEObjectReference obj);
  259. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference obj);
  260. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  261.         WEObjectReference obj);
  262. typedef pascal Boolean (*WEClickObjectProcPtr)(Point hitPt, EventModifiers modifiers, unsigned long clickTime,
  263.         WEObjectReference obj);
  264. typedef pascal OSErr (*WEStreamObjectProcPtr)(short destKind, FlavorType *theType,
  265.         Handle putDataHere, WEObjectReference obj);
  266.  
  267.  
  268. /*    UPP proc info */
  269.  
  270. enum {
  271.     uppWEClickLoopProcInfo = kPascalStackBased
  272.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  273.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  274. };
  275. enum {
  276.     uppWEScrollProcInfo = kPascalStackBased
  277.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  278. };
  279. enum {
  280.     uppWETSMPreUpdateProcInfo = kPascalStackBased
  281.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  282. };
  283. enum {
  284.     uppWETSMPostUpdateProcInfo = kPascalStackBased
  285.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEReference /*we*/)))
  286.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*fixLength*/)))
  287.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*inputAreaStart*/)))
  288.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*inputAreaEnd*/)))
  289.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(long /*pinRangeStart*/)))
  290.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long /*pinRangeEnd*/)))
  291. };
  292. enum {
  293.     uppWETranslateDragProcInfo = kPascalStackBased
  294.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  295.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(DragReference /*theDrag*/)))
  296.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(ItemReference /*theItem*/)))
  297.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(FlavorType /*requestedType*/)))
  298.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  299. };
  300. enum {
  301.     uppWEDrawTextProcInfo = kPascalStackBased
  302.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  303.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  304.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  305.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  306.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(WEReference /*we*/)))
  307. };
  308. enum {
  309.     uppWEPixelToCharProcInfo = kPascalStackBased
  310.         | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  311.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  312.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  313.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  314.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(Fixed * /*pixelWidth*/)))
  315.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(char * /*edge*/)))
  316.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  317.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(Fixed /*hPos*/)))
  318.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  319. };
  320. enum {
  321.     uppWECharToPixelProcInfo = kPascalStackBased
  322.         | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  323.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  324.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  325.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(Fixed /*slop*/)))
  326.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*offset*/)))
  327.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(short /*direction*/)))
  328.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(JustStyleCode /*styleRunPosition*/)))
  329.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(long /*hPos*/)))
  330.         | STACK_ROUTINE_PARAMETER(8,SIZE_CODE(sizeof(WEReference /*we*/)))
  331. };
  332. enum {
  333.     uppWELineBreakProcInfo = kPascalStackBased
  334.         | RESULT_SIZE(SIZE_CODE(sizeof(StyledLineBreakCode )))
  335.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  336.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(long /*textLength*/)))
  337.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(long /*textStart*/)))
  338.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(long /*textEnd*/)))
  339.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(Fixed * /*textWidth*/)))
  340.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(long * /*textOffset*/)))
  341.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  342. };
  343. enum {
  344.     uppWEWordBreakProcInfo = kPascalStackBased
  345.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  346.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textLength*/)))
  347.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(short /*offset*/)))
  348.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(char /*edge*/)))
  349.         | STACK_ROUTINE_PARAMETER(5,SIZE_CODE(sizeof(OffsetTable * /*breakOffsets*/)))
  350.         | STACK_ROUTINE_PARAMETER(6,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  351.         | STACK_ROUTINE_PARAMETER(7,SIZE_CODE(sizeof(WEReference /*we*/)))
  352. };
  353. enum {
  354.     uppWECharByteProcInfo = kPascalStackBased
  355.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  356.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  357.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  358.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  359.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  360. };
  361. enum {
  362.     uppWECharTypeProcInfo = kPascalStackBased
  363.         | RESULT_SIZE(SIZE_CODE(sizeof(short )))
  364.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Ptr /*pText*/)))
  365.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(short /*textOffset*/)))
  366.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(ScriptCode * /*script*/)))
  367.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEReference /*we*/)))
  368. };
  369.  
  370.  
  371. enum {
  372.     uppWENewObjectProcInfo = kPascalStackBased
  373.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  374.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point * /*defaultObjectSize*/)))
  375.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  376. };
  377. enum {
  378.     uppWEDisposeObjectProcInfo = kPascalStackBased
  379.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  380.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  381. };
  382. enum {
  383.     uppWEDrawObjectProcInfo = kPascalStackBased
  384.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  385.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(const Rect * /*destRect*/)))
  386.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  387. };
  388. enum {
  389.     uppWEClickObjectProcInfo = kPascalStackBased
  390.         | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  391.         | STACK_ROUTINE_PARAMETER(1,SIZE_CODE(sizeof(Point /*hitPt*/)))
  392.         | STACK_ROUTINE_PARAMETER(2,SIZE_CODE(sizeof(EventModifiers /*modifiers*/)))
  393.         | STACK_ROUTINE_PARAMETER(3,SIZE_CODE(sizeof(unsigned long /*clickTime*/)))
  394.         | STACK_ROUTINE_PARAMETER(4,SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  395. };
  396. enum {
  397.     uppWEStreamObjectProcInfo = kPascalStackBased
  398.         | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  399.         | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short /*destKind*/)))
  400.         | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(FlavorType * /*theType*/)))
  401.         | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle /*putDataHere*/)))
  402.         | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(WEObjectReference /*obj*/)))
  403. };
  404.  
  405.  
  406. /*    UPPs, New≈Proc macros & Call≈Proc macros */
  407.  
  408. /*
  409.     NOTE:
  410.     For compatibility with the Pascal version, Call≈Proc macros take the form:
  411.  
  412.         CallFooProc(..., userRoutine)
  413.  
  414.     instead of:
  415.  
  416.         CallFooProc(userRoutine, ...)
  417.  
  418. */
  419.  
  420. #if GENERATINGCFM
  421.  
  422. typedef UniversalProcPtr WEClickLoopUPP;
  423. typedef UniversalProcPtr WEScrollUPP;
  424. typedef UniversalProcPtr WETSMPreUpdateUPP;
  425. typedef UniversalProcPtr WETSMPostUpdateUPP;
  426. typedef UniversalProcPtr WETranslateDragUPP;
  427. typedef UniversalProcPtr WEDrawTextUPP;
  428. typedef UniversalProcPtr WEPixelToCharUPP;
  429. typedef UniversalProcPtr WECharToPixelUPP;
  430. typedef UniversalProcPtr WELineBreakUPP;
  431. typedef UniversalProcPtr WEWordBreakUPP;
  432. typedef UniversalProcPtr WECharByteUPP;
  433. typedef UniversalProcPtr WECharTypeUPP;
  434. typedef UniversalProcPtr WENewObjectUPP;
  435. typedef UniversalProcPtr WEDisposeObjectUPP;
  436. typedef UniversalProcPtr WEDrawObjectUPP;
  437. typedef UniversalProcPtr WEClickObjectUPP;
  438. typedef UniversalProcPtr WEStreamObjectUPP;
  439.  
  440. #define NewWEClickLoopProc(userRoutine) \
  441.     (WEClickLoopUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickLoopProcInfo, GetCurrentArchitecture())
  442. #define NewWEScrollProc(userRoutine) \
  443.     (WEScrollUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEScrollProcInfo, GetCurrentArchitecture())
  444. #define NewWETSMPreUpdateProc(userRoutine) \
  445.     (WETSMPreUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPreUpdateProcInfo, GetCurrentArchitecture())
  446. #define NewWETSMPostUpdateProc(userRoutine) \
  447.     (WETSMPostUpdateUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETSMPostUpdateProcInfo, GetCurrentArchitecture())
  448. #define NewWETranslateDragProc(userRoutine) \
  449.     (WETranslateDragUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWETranslateDragProcInfo, GetCurrentArchitecture())
  450. #define NewWEDrawTextProc(userRoutine) \
  451.     (WEDrawTextUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawTextProcInfo, GetCurrentArchitecture())
  452. #define NewWEPixelToCharProc(userRoutine) \
  453.     (WEPixelToCharUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEPixelToCharProcInfo, GetCurrentArchitecture())
  454. #define NewWECharToPixelProc(userRoutine) \
  455.     (WECharToPixelUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharToPixelProcInfo, GetCurrentArchitecture())
  456. #define NewWELineBreakProc(userRoutine) \
  457.     (WELineBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWELineBreakProcInfo, GetCurrentArchitecture())
  458. #define NewWEWordBreakProc(userRoutine) \
  459.     (WEWordBreakUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEWordBreakProcInfo, GetCurrentArchitecture())
  460. #define NewWECharByteProc(userRoutine) \
  461.     (WECharByteUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharByteProcInfo, GetCurrentArchitecture())
  462. #define NewWECharTypeProc(userRoutine) \
  463.     (WECharTypeUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWECharTypeProcInfo, GetCurrentArchitecture())
  464. #define NewWENewObjectProc(userRoutine) \
  465.     (WENewObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWENewObjectProcInfo, GetCurrentArchitecture())
  466. #define NewWEDisposeObjectProc(userRoutine) \
  467.     (WEDisposeObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDisposeObjectProcInfo, GetCurrentArchitecture())
  468. #define NewWEDrawObjectProc(userRoutine) \
  469.     (WEDrawObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEDrawObjectProcInfo, GetCurrentArchitecture())
  470. #define NewWEClickObjectProc(userRoutine) \
  471.     (WEClickObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEClickObjectProcInfo, GetCurrentArchitecture())
  472. #define NewWEStreamObjectProc(userRoutine) \
  473.     (WEStreamObjectUPP) NewRoutineDescriptor((ProcPtr) (userRoutine), uppWEStreamObjectProcInfo, GetCurrentArchitecture())
  474.  
  475. #define CallWEClickLoopProc(we, userRoutine) \
  476.     CallUniversalProc((userRoutine), uppWEClickLoopProcInfo, (we))
  477. #define CallWEScrollProc(we, userRoutine) \
  478.     CallUniversalProc((userRoutine), uppWEScrollProcInfo, (we))
  479. #define CallWETSMPreUpdateProc(we, userRoutine) \
  480.     CallUniversalProc((userRoutine), uppWETSMPreUpdateProcInfo, (we))
  481. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  482.     CallUniversalProc((userRoutine), uppWETSMPostUpdateProcInfo, (we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  483. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  484.     CallUniversalProc((userRoutine), uppWETranslateDragProcInfo, (theDrag), (theItem), (requestedType), (putDataHere))
  485. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  486.     CallUniversalProc((userRoutine), uppWEDrawTextProcInfo, (pText), (textLength), (slop), (styleRunPosition), (we))
  487. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  488.     CallUniversalProc((userRoutine), uppWEPixelToCharProcInfo, (pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  489. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  490.     CallUniversalProc((userRoutine), uppWECharToPixelProcInfo, (pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  491. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  492.     CallUniversalProc((userRoutine), uppWELineBreakProcInfo, (pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  493. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  494.     CallUniversalProc((userRoutine), uppWEWordBreakProcInfo, (pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  495. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  496.     CallUniversalProc((userRoutine), uppWECharByteProcInfo, (pText), (textOffset), (script), (we))
  497. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  498.     CallUniversalProc((userRoutine), uppWECharTypeProcInfo, (pText), (textOffset), (script), (we))
  499. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  500.     CallUniversalProc((userRoutine), uppWENewObjectProcInfo, (defaultObjectSize), (obj))
  501. #define CallWEDisposeObjectProc(obj, userRoutine) \
  502.     CallUniversalProc((userRoutine), uppWEDisposeObjectProcInfo, (obj))
  503. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  504.     CallUniversalProc((userRoutine), uppWEDrawObjectProcInfo, (destRect), (obj))
  505. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  506.     CallUniversalProc((userRoutine), uppWEClickObjectProcInfo, (hitPt), (modifiers), (clickTime), (obj))
  507. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  508.     CallUniversalProc((userRoutine), uppWEStreamObjectProcInfo, (destKind), (theType), (putDataHere), (obj))
  509.  
  510. #else
  511.  
  512. typedef WEClickLoopProcPtr WEClickLoopUPP;
  513. typedef WEScrollProcPtr WEScrollUPP;
  514. typedef WETSMPreUpdateProcPtr WETSMPreUpdateUPP;
  515. typedef WETSMPostUpdateProcPtr WETSMPostUpdateUPP;
  516. typedef WETranslateDragProcPtr WETranslateDragUPP;
  517. typedef WEDrawTextProcPtr WEDrawTextUPP;
  518. typedef WEPixelToCharProcPtr WEPixelToCharUPP;
  519. typedef WECharToPixelProcPtr WECharToPixelUPP;
  520. typedef WELineBreakProcPtr WELineBreakUPP;
  521. typedef WEWordBreakProcPtr WEWordBreakUPP;
  522. typedef WECharByteProcPtr WECharByteUPP;
  523. typedef WECharTypeProcPtr WECharTypeUPP;
  524. typedef WENewObjectProcPtr WENewObjectUPP;
  525. typedef WEDisposeObjectProcPtr WEDisposeObjectUPP;
  526. typedef WEDrawObjectProcPtr WEDrawObjectUPP;
  527. typedef WEClickObjectProcPtr WEClickObjectUPP;
  528. typedef WEStreamObjectProcPtr WEStreamObjectUPP;
  529.  
  530. #define NewWEClickLoopProc(userRoutine) ((WEClickLoopUPP) (userRoutine))
  531. #define NewWEScrollProc(userRoutine) ((WEScrollUPP) (userRoutine))
  532. #define NewWETSMPreUpdateProc(userRoutine) ((WETSMPreUpdateUPP) (userRoutine))
  533. #define NewWETSMPostUpdateProc(userRoutine) ((WETSMPostUpdateUPP) (userRoutine))
  534. #define NewWETranslateDragProc(userRoutine) ((WETranslateDragUPP) (userRoutine))
  535. #define NewWEDrawTextProc(userRoutine) ((WEDrawTextUPP) (userRoutine))
  536. #define NewWEPixelToCharProc(userRoutine) ((WEPixelToCharUPP) (userRoutine))
  537. #define NewWECharToPixelProc(userRoutine) ((WECharToPixelUPP) (userRoutine))
  538. #define NewWELineBreakProc(userRoutine) ((WELineBreakUPP) (userRoutine))
  539. #define NewWEWordBreakProc(userRoutine) ((WEWordBreakUPP) (userRoutine))
  540. #define NewWECharByteProc(userRoutine) ((WECharByteUPP) (userRoutine))
  541. #define NewWECharTypeProc(userRoutine) ((WECharTypeUPP) (userRoutine))
  542. #define NewWENewObjectProc(userRoutine) ((WENewObjectUPP) (userRoutine))
  543. #define NewWEDisposeObjectProc(userRoutine) ((WEDisposeObjectUPP) (userRoutine))
  544. #define NewWEDrawObjectProc(userRoutine) ((WEDrawObjectUPP) (userRoutine))
  545. #define NewWEClickObjectProc(userRoutine) ((WEClickObjectUPP) (userRoutine))
  546. #define NewWEStreamObjectProc(userRoutine) ((WEStreamObjectUPP) (userRoutine))
  547.  
  548. #define CallWEClickLoopProc(we, userRoutine) \
  549.     (*(userRoutine))((we))
  550. #define CallWEScrollProc(we, userRoutine) \
  551.     (*(userRoutine))((we))
  552. #define CallWETSMPreUpdateProc(we, userRoutine) \
  553.     (*(userRoutine))((we))
  554. #define CallWETSMPostUpdateProc(we, fixLength, inputAreaStart, inputAreaEnd, pinRangeStart, pinRangeEnd, userRoutine) \
  555.     (*(userRoutine))((we), (fixLength), (inputAreaStart), (inputAreaEnd), (pinRangeStart), (pinRangeEnd))
  556. #define CallWETranslateDragProc(theDrag, theItem, requestedType, putDataHere, userRoutine) \
  557.     (*(userRoutine))((theDrag), (theItem), (requestedType), (putDataHere))
  558. #define CallWEDrawTextProc(pText, textLength, slop, styleRunPosition, we, userRoutine) \
  559.     (*(userRoutine))((pText), (textLength), (slop), (styleRunPosition), (we))
  560. #define CallWEPixelToCharProc(pText, textLength, slop, pixelWidth, edge, styleRunPosition, hPos, we, userRoutine) \
  561.     (*(userRoutine))((pText), (textLength), (slop), (pixelWidth), (edge), (styleRunPosition), (hPos), (we))
  562. #define CallWECharToPixelProc(pText, textLength, slop, offset, direction, styleRunPosition, hPos, we, userRoutine) \
  563.     (*(userRoutine))((pText), (textLength), (slop), (offset), (direction), (styleRunPosition), (hPos), (we))
  564. #define CallWELineBreakProc(pText, textLength, textStart, textEnd, textWidth, textOffset, we, userRoutine) \
  565.     (*(userRoutine))((pText), (textLength), (textStart), (textEnd), (textWidth), (textOffset), (we))
  566. #define CallWEWordBreakProc(pText, textLength, offset, edge, breakOffsets, script, we, userRoutine) \
  567.     (*(userRoutine))((pText), (textLength), (offset), (edge), (breakOffsets), (script), (we))
  568. #define CallWECharByteProc(pText, textOffset, script, we, userRoutine) \
  569.     (*(userRoutine))((pText), (textOffset), (script), (we))
  570. #define CallWECharTypeProc(pText, textOffset, script, we, userRoutine) \
  571.     (*(userRoutine))((pText), (textOffset), (script), (we))
  572. #define CallWENewObjectProc(defaultObjectSize, obj, userRoutine) \
  573.     (*(userRoutine))((defaultObjectSize), (obj))
  574. #define CallWEDisposeObjectProc(obj, userRoutine) \
  575.     (*(userRoutine))((obj))
  576. #define CallWEDrawObjectProc(destRect, obj, userRoutine) \
  577.     (*(userRoutine))((destRect), (obj))
  578. #define CallWEClickObjectProc(hitPt, modifiers, clickTime, obj, userRoutine) \
  579.     (*(userRoutine))((hitPt), (modifiers), (clickTime), (obj))
  580. #define CallWEStreamObjectProc(destKind, theType, putDataHere, obj, userRoutine) \
  581.     (*(userRoutine))((destKind), (theType), (putDataHere), (obj))
  582.  
  583. #endif
  584.  
  585.  
  586. /*    WASTE public calls */
  587.  
  588. #ifdef __cplusplus
  589. extern "C" {
  590. #endif
  591.  
  592. /*    creation and destruction */
  593.  
  594. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, unsigned long flags, WEReference *we);
  595. pascal void WEDispose(WEReference we);
  596.  
  597. /*    getting variables */
  598.  
  599. pascal Handle WEGetText(WEReference we);
  600. pascal short WEGetChar(long offset, WEReference we);
  601. pascal long WEGetTextLength(WEReference we);
  602. pascal long WECountLines(WEReference we);
  603. pascal long WEGetHeight(long startLine, long endLine, WEReference we);
  604. pascal void WEGetSelection(long *selStart, long *selEnd, WEReference we);
  605. pascal void WEGetDestRect(LongRect *destRect, WEReference we);
  606. pascal void WEGetViewRect(LongRect *viewRect, WEReference we);
  607. pascal Boolean WEIsActive(WEReference we);
  608. pascal long WEOffsetToLine (long offset, WEReference we);
  609. pascal void WEGetLineRange(long lineNo, long *lineStart, long *lineEnd, WEReference we);
  610.  
  611. /*    setting variables */
  612.  
  613. pascal void WESetSelection(long selStart, long selEnd, WEReference we);
  614. pascal void WESetDestRect(const LongRect *destRect, WEReference we);
  615. pascal void WESetViewRect(const LongRect *viewRect, WEReference we);
  616.  
  617. /*    accessing style run information */
  618.  
  619. pascal Boolean WEContinuousStyle(WEStyleMode *mode, TextStyle *ts, WEReference we);
  620. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEReference we);
  621.  
  622. /*    converting byte offsets to screen position and vice versa */
  623.  
  624. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEReference we);
  625. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEReference we);
  626.  
  627. /*    finding words and lines */
  628.  
  629. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEReference we);
  630. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEReference we);
  631.  
  632. /*    making a copy of a text range */
  633.  
  634. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  635.  
  636. /*    getting and setting the alignment style */
  637.  
  638. pascal WEAlignment WEGetAlignment(WEReference we);
  639. pascal void WESetAlignment(WEAlignment alignment, WEReference we);
  640.  
  641. /*    recalculating line breaks, drawing and scrolling */
  642.  
  643. pascal OSErr WECalText(WEReference we);
  644. pascal void WEUpdate(RgnHandle updateRgn, WEReference we);
  645. pascal void WEScroll(long hOffset, long vOffset, WEReference we);
  646. pascal void WESelView(WEReference we);
  647.  
  648. /*    handling activate / deactivate events */
  649.  
  650. pascal void WEActivate(WEReference we);
  651. pascal void WEDeactivate(WEReference we);
  652.  
  653. /*     handling key-down events */
  654.  
  655. pascal void WEKey(short key, EventModifiers modifiers, WEReference we);
  656.  
  657. /*    handling mouse-down events and mouse tracking */
  658.  
  659. pascal void WEClick(Point hitPt, EventModifiers modifiers, unsigned long clickTime, WEReference we);
  660.  
  661. /*    adjusting the cursor shape */
  662.  
  663. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEReference we);
  664.  
  665. /*    blinking the caret */
  666.  
  667. pascal void WEIdle(unsigned long *maxSleep, WEReference we);
  668.  
  669. /*    modifying the text and the styles */
  670.  
  671. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEReference we);
  672. pascal OSErr WEDelete(WEReference we);
  673. pascal OSErr WESetStyle(WEStyleMode mode, const TextStyle *ts, WEReference we);
  674. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEReference we);
  675. pascal OSErr WEUseText(Handle hText, WEReference we);
  676.  
  677. /*    undo */
  678.  
  679. pascal OSErr WEUndo(WEReference we);
  680. pascal void WEClearUndo(WEReference we);
  681. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEReference we);
  682. pascal Boolean WEIsTyping(WEReference we);
  683.  
  684. /*    keeping track of changes */
  685.  
  686. pascal unsigned long WEGetModCount(WEReference we);
  687. pascal void WEResetModCount(WEReference we);
  688.  
  689. /*    embedded objects */
  690.  
  691. pascal OSErr WEInstallObjectHandler(FlavorType objectType, WESelector handlerSelector, UniversalProcPtr handler, WEReference we);
  692. pascal OSErr WEInsertObject(FlavorType objectType, Handle objectDataHandle, Point objectSize, WEReference we);
  693. pascal OSErr WEGetSelectedObject(WEObjectReference *obj, WEReference we);
  694. pascal long WEFindNextObject(long offset, WEObjectReference *obj, WEReference we);
  695. pascal OSErr WEUseSoup(WESoupHandle hSoup, WEReference we);
  696.  
  697. /*    accessing embedded object attributes */
  698.  
  699. pascal FlavorType WEGetObjectType(WEObjectReference obj);
  700. pascal Handle WEGetObjectDataHandle(WEObjectReference obj);
  701. pascal Point WEGetObjectSize(WEObjectReference obj);
  702. pascal WEReference WEGetObjectOwner(WEObjectReference obj);
  703. pascal long WEGetObjectRefCon(WEObjectReference obj);
  704. pascal void WESetObjectRefCon(WEObjectReference obj, long refCon);
  705.  
  706. /*    clipboard operations */
  707.  
  708. pascal OSErr WECut(WEReference we);
  709. pascal OSErr WECopy(WEReference we);
  710. pascal OSErr WEPaste(WEReference we);
  711. pascal Boolean WECanPaste(WEReference we);
  712.  
  713. /*    Drag Manager support */
  714.  
  715. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEReference we);
  716. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEReference we);
  717. pascal OSErr WEReceiveDrag(DragReference drag, WEReference we);
  718. pascal Boolean WECanAcceptDrag(DragReference drag, WEReference we);
  719. pascal Boolean WEDraggedToTrash(DragReference drag);
  720.  
  721. /*    Script Manager utilities */
  722.  
  723. pascal short WECharByte(long offset, WEReference we);
  724. pascal short WECharType(long offset, WEReference we);
  725.  
  726. /*    Text Services Manager support */
  727.  
  728. pascal OSErr WEInstallTSMHandlers(void);
  729. pascal OSErr WERemoveTSMHandlers(void);
  730. pascal void WEStopInlineSession(WEReference we);
  731.  
  732. /*    additional features */
  733.  
  734. pascal short WEFeatureFlag(short feature, short action, WEReference we);
  735. pascal OSErr WEGetInfo(WESelector selector, void *info, WEReference we);
  736. pascal OSErr WESetInfo(WESelector selector, const void *info, WEReference we);
  737.  
  738. /*    long coordinate utilities */
  739.  
  740. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  741. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  742. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  743. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  744. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  745. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  746. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  747.  
  748. #ifdef __cplusplus
  749. }
  750. #endif
  751.  
  752. #if defined(powerc) || defined (__powerc)
  753. #pragma options align=reset
  754. #endif
  755.  
  756. #endif
  757.